<?php

namespace coreapi\modules\controllers;

use coreapi\controllers\BaseSwooleController;
use common\components\DoraRPC\DoraConst;

/**
 * 基础信息
 * @author jianbiao11
 */
class TestController extends BaseSwooleController {


	public function actionIndex(){

      $result_model=$this->swoole_client->getConnectMode();
      $result_stat= $this->swoole_client->getStat();
      /*
      $result_stat=[];
      $result=[];
      do {
      	 $result_stat= $this->swoole_client->getStat();
      	 if(!empty($result_stat)){
      	 	$result= $this->swoole_client->singleAPI("activity/test",['a'=>1,'b'=>2]);
      	 	$result_stat=false;
      	 }
      } while ($result_stat);
      */

      $result= $this->swoole_client->singleAPI("activity/test",['a'=>1,'b'=>2],DoraConst::SW_MODE_WAITRESULT,4);

  	  return $this->returnSuccessJson(['model'=> $result_model,'stat'=>$result_stat,'result'=>$result]);
	}

    
	public function actionIndex2(){

      $result_model=$this->swoole_client->getConnectMode();
      $result= $this->swoole_client->singleAPI("activity/test",['a'=>1,'b'=>2],DoraConst::SW_MODE_NORESULT,4);
  	  return $this->returnSuccessJson(['model'=> $result_model,'result'=>$result]);
	}

	public function actionIndex3(){

      $result_model=$this->swoole_client->getConnectMode();
      $result= $this->swoole_client->singleAPI("activity/test",['a'=>1,'b'=>2],DoraConst::SW_MODE_ASYNCRESULT,4);
      $result_asyn= $this->swoole_client->getAsyncData();
  	  return $this->returnSuccessJson(['model'=> $result_model,'result'=>$result,'result_asyn'=>$result_asyn]);
	}



}
